const RoleModel = require("../model/RoleModel")

const RoleServices = {
    find: (roleInfo, pages = { limit: 1, size: 10 }) => {
        const { limit, size } = pages
        return RoleModel.find(Object.assign(roleInfo)).skip((limit - 1) * size).limit(size).sort({ sort: -1 })
    },
    append: (roleInfo) => {
        return RoleModel.create(roleInfo)
    },
    update: (roleInfo) => {
        return RoleModel.updateOne({ _id: roleInfo._id }, roleInfo)
    },
    remove: (id) => {
        return RoleModel.deleteOne({ _id: id })
    },
}

module.exports = RoleServices